package projectEuler.net;

public class Problem_050 {
	private static boolean[] lstPrimes;
	private static int nPrimes;
	private static int pPrime;
	private static int[] lPrimes;
	
	private static void initialize(){
		setLstPrimes(PrimesGenerator.genPrimes(1000000));
		setnPrimes(0);
		setpPrime(0);
	}
	public static void findLongestConsecutivePrimes(){
		int sum = 0;
		int cnt = 0;
		initialize();
		for(int j=0; j<lstPrimes.length; j++)
			if(lstPrimes[j]){
				sum=cnt=0;
				for(int i=j; i<lstPrimes.length; i++){
					if(lstPrimes[i]&&(sum<lstPrimes.length - i)){
						sum+=i;
						cnt++;
						if(lstPrimes[sum] && (cnt>nPrimes)){
							setnPrimes(cnt);
							setpPrime(sum);
						}
					}
				}
			}
		System.out.printf("__%d__%d\n", nPrimes, pPrime);
	}
	public static void setLstPrimes(boolean[] lstPrimes) {
		Problem_050.lstPrimes = lstPrimes;
	}
	public static boolean[] getLstPrimes() {
		return lstPrimes;
	}
	public static void setnPrimes(int nPrimes) {
		Problem_050.nPrimes = nPrimes;
	}
	public static int getnPrimes() {
		return nPrimes;
	}
	public static void setlPrimes(int[] lPrimes) {
		Problem_050.lPrimes = lPrimes;
	}
	public static int[] getlPrimes() {
		return lPrimes;
	}
	public static void setpPrime(int pPrime) {
		Problem_050.pPrime = pPrime;
	}
	public static int getpPrime() {
		return pPrime;
	}
}
